<?php
include_once(PATH_SQL . 'product_sql.php');
include_once(PATH_MODEL . 'product_model.php');
include_once(PATH_VIEW_ADMIN . 'product_view.php');
include_once(PATH_INCLUDE."thumb.php");
include_once(PATH_INCLUDE."constant.php");

$oModelProduct=new Model_Product();
$oViewProduct = new View_Product($oModelProduct);
$oModelProduct->setData('page_size',100);
$oModelProduct->setData('pagegroup_size',20);
$oModelProduct->setData('stylesheet',"paging");
$sAction=$_REQUEST['sAction'];

switch($sAction) {
    case "export_csv": {
            set_time_limit(600);
            ini_set('post_max_size', '64M');
            ini_set('memory_limit', '64M');
            error_reporting( E_ALL );
            $oViewProduct->display_csv($oModelProduct);
            $array_header = $oModelProduct->aLanguage['HEADER_CSV_FILE'];
            $arrProduct = $_POST['productID'];
            
            if(count($arrProduct)>0) {
                foreach($_POST['productSelected'] as $key => $value) {
                    $text .= "'".$value."',";
                }
                $condition = substr($text,0,strlen($text)-1);
            } else {
                $condition = "";
            }
            $csv = '';
            if($_REQUEST['filename'] == "" || $_REQUEST['filename'] == "null") {
                $setFileName = "auctions". date("Y"). date("m"). date("d") ;
            } else {
                $setFileName = $_REQUEST['filename'];
            }
            folderDelete(PATH_ROOT."auctions");
            if(!is_dir(PATH_ROOT.'auctions/'))
                mkdir(PATH_ROOT."auctions",777);
            //$fp = fopen(PATH_ROOT.'auctions/'. $setFileName .'.csv','w');
            $fp = fopen(PATH_ROOT.'auctions/auctions.csv','w');
            foreach ($array_header as $header) {
                $header	= mb_convert_encoding($header,"SJIS","UTF-8");
                $csv .= '"'.$header.'",';
                $arr_header[]=$header;
            }
            $csv = substr($csv,0,strlen($csv)-1);
            $csv .= "\n";
            $sCSV_header = $csv;
            $aData = $oModelProduct->getListExportCsv($condition);
			$sql_d = "SELECT * FROM ams_product_defaul WHERE 1 = 1";
            $rs_d = mysql_query($sql_d);
			$row_d = mysql_fetch_array($rs_d);
			$csv = "";
			//if($row_d['product_payment_method'] == 1) $row_d['product_payment_method'] = 'はい';
			//else $row_d['product_payment_method'] = 'いいえ';
			if (is_array($aData)){
                foreach($aData as $row) {
					if(($row['product_payment_method'] == 0) || ($row['product_payment_method'] == "")) $row['product_payment_method'] = $row_d['product_payment_method'];
					//echo $row['product_payment_method']; die();
                    $csv .= $oModelProduct->doExportSingleRow( $row );
					//print_r($row); die();
                }
            }
            //$check_backup=$oModelProduct->backUpAfterExortCsv();
            $csv = $sCSV_header.$csv;
            $csv = str_replace(", ",",",$csv);
            $csv = str_replace(",  ",",",$csv);
            $csv = str_replace(" ,",",",$csv);
            ob_clean();
            fwrite($fp, $csv);
            fclose($fp);
			$zipName = $setFileName.".zip";
            /*
            include_once("CreateZipFile.inc.php");
            $createZipFile = new CreateZipFile;
            $directoryToZip = "auctions";  //This will zip all the file(s) in this present working directory
            $outputDir = '';  //Replace "/" //with the name of the desired output directory.
            $zipName = $setFileName.".zip";
            $createZipFile->zipDirectory( $directoryToZip, $outputDir, "auctions/" );
            $fd = fopen(PATH_ROOT.'upload/'.$zipName, "w");
            $out = fwrite($fd, $createZipFile->getZippedfile());
            fclose($fd); 
            $createZipFile->forceDownload( PATH_ROOT.'upload/'.$zipName );
            die();
			*/
			
			require "zip.class.php"; // Get the zipfile class
			$zipfile = new zipfile; // Create an object
			//$zipfile->create_dir(PATH_ROOT.'upload/'.$setFileName); // Add a subdirectory - must be done.  If a subdirectory is not wanted, just simply add one named "." as shown here
			$tmp = $zipfile->parseDirectory(PATH_ROOT.'auctions');
			$count=count($tmp);
			for ($i=0;$i<$count;$i++){
				$zipfile->create_file(file_get_contents($tmp[$i]), basename($tmp[$i]));
			}
			
			// Allow user to download file
			header("Content-type: application/zip");
			header("Content-disposition: attachment;filename=\"".$zipName."\"");
			echo $zipfile->zipped_file(); 
            break;
        }
    case "update_size": {
            $oViewProduct->displayAddNewForm($oModelProduct);
            $oViewProduct->ajaxGetCurrentAtr($oModelProduct,$_REQUEST['product_id']);
            die();
            break;
        }
    case "AJAX_RELOAD_IMAGE": {
            $oViewProduct->displayAddNewForm($oModelProduct);
            $oViewProduct->imageOfThisP_Ajax($oModelProduct,$_REQUEST['product_id']);
            die();
            break;
        }
    case "filterProduct": {
            $oViewProduct->displayManagerIndex($oModelProduct);
            $oModelProduct->setData('fromDate',$_REQUEST['fromDate']);
            $oModelProduct->setData('toDate',$_REQUEST['toDate']);
            $oViewProduct->resultXML_filterProduct($oModelProduct);
            die();
            break;
        }
    case "filterProduct_normal": {
        //			echo "4234234"; die();
            $oViewProduct->displayManagerIndex($oModelProduct);
            $oModelProduct->setData('fromDate', $_REQUEST['fromDate']);
            $oModelProduct->setData('toDate', $_REQUEST['toDate']);
            $oModelProduct->setData('category', $_REQUEST['category']);
            unset($_SESSION['fromDate']);
            unset($_SESSION['toDate']);
            unset($_SESSION['category']);
            $_SESSION['fromDate'] = $_REQUEST['fromDate'];
            $_SESSION['toDate'] = $_REQUEST['toDate'];
            $_SESSION['category'] = $_REQUEST['category'];
            $oViewProduct->filterProduct($oModelProduct);
            break;
        }
    case 'update_status': {
            $oModelProduct->unsetData('id');
            $oModelProduct->unsetData('product_yahoo_point');
            if (count($_POST['product_title'] > 0)) {
                foreach ($_POST['product_title'] as $sKey => $sValue) {
                    $oModelProduct->setData('id', $sKey);
                    $oModelProduct->setData('product_icon_gift', intval($_POST['product_icon_gift'][$sKey]));
                    $oModelProduct->setData('product_store_hot_auction', intval($_POST['product_store_hot_auction'][$sKey]));
                    $oModelProduct->setData('product_bakground_color', intval($_POST['product_bakground_color'][$sKey]));
                    $oModelProduct->setData('product_title_bold_line', intval($_POST['product_title_bold_line'][$sKey]));
                    $oModelProduct->setData('product_have_to_negotiate_discount', intval($_POST['product_have_to_negotiate_discount'][$sKey]));
                    $oModelProduct->setData('product_prices_start', intval($_POST['product_prices_start'][$sKey]));
                    $oModelProduct->setData('product_price_fastener', intval($_POST['product_price_fastener'][$sKey]));
                    if($_POST['product_key'][$sKey] == 0 AND $_POST['product_key'][$sKey] != ''){
                        $oModelProduct->setData('product_key_select', '1');
                        $oModelProduct->setData('product_key1', $_POST['product_key'][$sKey]);
                    }elseif($_POST['product_key'][$sKey] > 0 AND $_POST['product_key'][$sKey] != ''){
                        $oModelProduct->setData('product_key'.$_POST['product_key'][$sKey], $_POST['product_key'][$sKey]);
                    }
                    $oModelProduct->setData('product_store', $_POST['product_store'][$sKey]);
                    $oModelProduct->setData('product_title', $_POST['product_title'][$sKey]);
                    $oModelProduct->updateProductStatus();
                    // Reset aData
                    $oModelProduct->aData = Array();
                }
            }
            if (isset($_SESSION['fromDate']) && isset($_SESSION['toDate'])){
                redir('?sMod=product_index&sAction=filterProduct_normal&fromDate='.$_SESSION['fromDate'].'&toDate='.$_SESSION['toDate']);
            }else{
                redir("?sMod=product_index");
            }
            break;
        }
    case "add_new_form": {
            $oModelProduct->setData("do_edit_or_add_new", "do_add_new");
            $oViewProduct->displayAddNewForm($oModelProduct);
            $oViewProduct->viewListProvince($oModelProduct);
            $oViewProduct->showAttributeAddNew($oModelProduct);
            
            $rs = $oViewProduct->displayListTemplate($oModelProduct, '');
            $oViewProduct->displayTemplateDefault($oModelProduct, $rs);
            $oViewProduct->displayRank($oModelProduct,'','');

            $oViewProduct->displayBlockProductBankInputDefault($oModelProduct);
            break;
        }
    case "do_add_new": {
            $_POST["product_date_added"] = date('Y-m-d H:i:s');
            $_POST["product_last_modified"] = date('Y-m-d H:i:s');
            $_POST["product_name"] = $_POST["product_title"];

            if($_POST['product_description_swich']==1) {
                $oModelProduct->setData('product_description_on_mobile',$_POST['product_description_on_mobile_unactive']);
            }

            $oModelProduct->setData("product_description", $_POST["product_description"]);
            $oModelProduct->setData("product_date_added", $_POST["product_date_added"]);
            $oModelProduct->setData("product_last_modified", $_POST["product_last_modified"]);
            $oModelProduct->setData("product_name", $_POST["product_title"]);
            $oModelProduct->setData("product_keyword_commodity", $_POST["product_keyword_commodity"]);
            $oModelProduct->setData("product_status", 1);
            $oModelProduct->setData("product_description_normal",1);// tab normal is selected
            if($_POST['product_person']=='') {
                $oModelProduct->setData("product_set_limit_on_prices",'');
            }
           /**
             * BANK && OTHER MOETHOD
             */
            $product_payment_method='';
            if(is_array($_POST['product_bank'])) {
                foreach($_POST['product_bank'] as $arr_row) {
                    if($arr_row!='') {	$product_payment_method=1;
                        $arr_bank_temp[]=$arr_row;
                    }
                }
                if(is_array($arr_bank_temp)) {
                    $arr_bank=implode('>*',$arr_bank_temp);
                }
                else
                    $arr_bank=null;
                $oModelProduct->setData('product_bank',$arr_bank);
            }
            if($product_payment_method==1 && $_POST['product_payment_method']==1) {

                $oModelProduct->setData('product_payment_method','1');
            }
            else {

                $oModelProduct->setData('product_payment_method','0');
            }
            //OTHER METHOD
            if(is_array($_POST['product_other_payment_method'])) {
                foreach($_POST['product_other_payment_method'] as $arr_row1) {
                    if($arr_row1!='') {
                        $arr_bank_temp1[]=$arr_row1;
                    }
                }
                if(is_array($arr_bank_temp1))
                    $arr_bank_other=implode('>*',$arr_bank_temp1);
                else
                    $arr_bank_other=null;
                $oModelProduct->setData('product_other_payment_method',$arr_bank_other);
            }

            $result = $oModelProduct->do_insert_new_product();
            if ($result == 0) {
                $result = true;
            }
            if (!$result) {
                $sErrorMsg = $oModelProduct->aLanguage['TEXT']['form_cannot_submit'] . $oModelProduct->aLanguage['TEXT']['alert_unique'];
                $oModelProduct->setErrorMsg($sErrorMsg);
            }else {
            // do update other method transport
                $aAllDataOther = array();
                for ($i=1; $i<11;$i++) {
                    if($_REQUEST["other_title_".$i]!='') {
                        $item = array('other_product_id'=>$result,
                            'other_title_of_method'=>$_REQUEST["other_title_".$i],
                            'other_link_to_price_list'=>$_REQUEST["other_link_to_price_list_".$i],
                            'other_uniform_price'=>$_REQUEST["other_uniform_price_".$i]
                        );
                        array_push($aAllDataOther,$item);
                    }
                }
                $resultUpdateOMoT = $oModelProduct->updateOMoT($oModelProduct->getData('id'),$aAllDataOther);
                redir('?sMod=product_index&status=insert_success');
            }
            break;
        }
    case 'do_delete': {
            $oModelProduct->setData('product_id', $oModelProduct->getData('id'));
            $result_del = $oModelProduct->deleteProduct();
            $result_del_image = $oModelProduct->deleteImageOfProduct();
            $oModelProduct->deleteProAtt();
            $oModelProduct->deleteOMoT($oModelProduct->getData('id'));

            if (!$result_del || !$result_del_image) {
                redir('?sMod=product_index&sSatus=delError');
                $sErrorMsg = $oModelProduct->aLanguage['TEXT']['cannot_delete'] . $oModelProduct->aLanguage['TEXT']['alert_unique'];
                $oModelProduct->setErrorMsg($sErrorMsg);
            } else {
                redir('?sMod=product_index&status=deletesucess');
            }
        }
    case "delete_products": {
            
           if(count($_POST['productSelected'])>0) {
                foreach($_POST[productSelected] as $key=>$value) {
                    $oModelProduct->setData('product_id', $value);
                    $rowProduct=$oModelProduct->getInfoProduct();
                    if($rowProduct['product_picture1'] !="" && file_exists(PATH_UPLOAD_PRODUCT.$rowProduct['product_picture1'])) {
                        unlink(PATH_UPLOAD_PRODUCT.$rowProduct['product_picture1']);
                        unlink(PATH_UPLOAD_PRODUCT."thumbnails/".$rowProduct['product_picture1']);
                    }
                    if($rowProduct['product_picture2'] !="" && file_exists(PATH_UPLOAD_PRODUCT.$rowProduct['product_picture2'])) {
                        unlink(PATH_UPLOAD_PRODUCT.$rowProduct['product_picture2']);
                        unlink(PATH_UPLOAD_PRODUCT."thumbnails/".$rowProduct['product_picture2']);
                    }
                    if($rowProduct['product_picture3'] !="" && file_exists(PATH_UPLOAD_PRODUCT.$rowProduct['product_picture3'])) {
                        unlink(PATH_UPLOAD_PRODUCT.$rowProduct['product_picture3']);
                        unlink(PATH_UPLOAD_PRODUCT."thumbnails/".$rowProduct['product_picture3']);
                    }
                    $result_del = $oModelProduct->deleteProduct();
                    $result_del_image = $oModelProduct->deleteImageOfProduct();
                    $oModelProduct->deleteProAtt();
                    $oModelProduct->deleteOMoT($value);
                }
            }
            redir('?sMod=product_index');
        }
    case 'edit_form': {
            $oModelProduct->setData("do_edit_or_add_new", "do_edit");
            $oModelProduct->setData('product_id', $oModelProduct->getData('id'));
            $oViewProduct->displayEditProductIndex($oModelProduct);
            $rs = $oViewProduct->displayInfoProduct($oModelProduct);
            $oViewProduct->displayListOMoT($oModelProduct, $oModelProduct->getData('id'));
            $rs_temp = $oViewProduct->displayListTemplate($oModelProduct,$rs);
            $oViewProduct->displayTemplateDefault($oModelProduct, $rs_temp, $rs);
            $oViewProduct->display_list_size_edit($oModelProduct,$rs['product_attribute']);
            $oViewProduct->displayRank($oModelProduct,$rs['product_rank_name'],$rs['product_condition']);
            $oViewProduct->displayBlockProductBankInputWithData($rs['product_bank']);
            $oViewProduct->displayBlockOtherPayMentMethodWithData($rs['product_other_payment_method']);
            $get_id_product = $_REQUEST['id'];
            $oModelProduct->setData('get_id_product',$get_id_product);
            break;
        }
    case 'defaul':{
            $oModelProduct->setData("do_edit_or_add_new","do_edit_defaul");
            
            if(($_REQUEST['sSatus']) &&($_REQUEST['sSatus']=="ok")) {
                $oModelProduct->setData('update_ok',"update successfully");
            }
            $oViewProduct->displayEditProductDefaul($oModelProduct);

            $oViewProduct->displayListOwner($oModelProduct,true);
            $owner_id = $oViewProduct->userID;
            $oModelProduct->setData('owner_id',$owner_id);
            
            $rs=$oViewProduct->displayInfoProductDefaul($oModelProduct);
            $oViewProduct->displayBlockProductBankInputWithData($rs['product_bank']);
            $oViewProduct->displayBlockOtherPayMentMethodWithData($rs['product_other_payment_method']);
            $oViewProduct->displayListOMoT_Defaul($oModelProduct,$owner_id);
            
            break;
        }
    case 'do_edit': {
            $oUpload = new Upload($_FILES);
            $oModelProduct->setData('product_id', $oModelProduct->getData('product_id'));
            $productID=$oModelProduct->getData('product_id');
            if(strlen($productID)==2) {
                $imageID=date("Y").date("m").date("d").ord(substr($productID,0,1)). "0" .substr($productID,1,1);
            }
            else {
                $imageID=date("Y").date("m").date("d").ord(substr($productID,0,1)).substr($productID,1,2);
            }
            $oModelProduct->setData('id', $oModelProduct->getData('product_id'));
            if (intval($_REQUEST["product_description_normal"]) == 0) {
                $_REQUEST["product_description"]  = $_REQUEST["product_description_html_tag"];
                $oModelProduct->setData("product_description",$_REQUEST["product_description"]);
            }
            $_REQUEST['product_pictures_comment']='';

            $arrayName = array("person", "product_send_cash", "product_POD", "product_credit_card", "product_transport_goods_abroad");

            $oModelProduct->setData("product_name",$_REQUEST["product_title"]);
            $oModelProduct->setData("product_yahoo_point_fees",$_REQUEST["product_yahoo_point_fees"]);
            $_REQUEST_2 = $oModelProduct->setDataForCheckbox($arrayName,$_REQUEST);
            $_REQUEST_2["product_last_modified"] = date('Y-m-d H:i:s');
            $oldProduct=$oModelProduct->getInfoProduct();
            for ($i=1;$i<=3;$i++) {
                $_REQUEST['product_pictures_comment'] .= $_REQUEST['product_pictures_comment_'.$i]."139211";
                $_REQUEST_2['product_picture_comment'.$i] = $_REQUEST['product_pictures_comment_'.$i];
                $oModelProduct->setData('product_picture_comment'.$i, $_REQUEST['product_pictures_comment_'.$i]);
	    }
            

            $oModelProduct->setData('product_pictures_comment', $_REQUEST['product_pictures_comment']);

            if($_REQUEST['product_person']=='') {
                $_REQUEST_2['product_set_limit_on_prices']='';
            }
            /**
             * BANK && OTHER MOETHOD
             */
            $product_payment_method='';
            if(is_array($_POST['product_bank'])) {
                foreach($_POST['product_bank'] as $arr_row) {
                    if($arr_row!='') {	$product_payment_method=1;
                        $arr_bank_temp[]=$arr_row;
                    }
                }
                if(is_array($arr_bank_temp)) {
                    $arr_bank=implode('>*',$arr_bank_temp);
                }
                else
                    $arr_bank = null;
                $_REQUEST_2['product_bank']=$arr_bank;
            }
            if($product_payment_method==1 && $_POST['product_payment_method']==1) {
                $_REQUEST_2['product_payment_method']=1;
            }
            else {

                $_REQUEST_2['product_payment_method']=0;
                $_REQUEST_2['product_bank']=null;
            }
            if($_REQUEST_2['product_affiliate']!=1) {
                $_REQUEST_2['product_affiliate']="";
            }
            //OTHER METHOD
            /**
             *
             */
            if(is_array($_POST['product_other_payment_method'])) {
                foreach($_POST['product_other_payment_method'] as $arr_row1) {
                    if($arr_row1!='') {
                        $arr_bank_temp1[]=$arr_row1;
                    }
                }
                if(is_array($arr_bank_temp1)) {
                    $arr_bank_other=implode('>*',$arr_bank_temp1);
                }
                else
                    $arr_bank_other=null;

                $_REQUEST_2['product_other_payment_method']=$arr_bank_other;
            }
            $_REQUEST_2['product_have_to_negotiate_discount'] = '0';
            $result_edit=$oModelProduct->updateProduct($_REQUEST_2);
            $result_editAttribute=$oModelProduct->updateAttribute($_REQUEST);

            // do update other method transport
            $aAllDataOther = array();
            for ($i=1; $i<11;$i++) {
                if($_REQUEST["other_title_".$i]!='') {
                    $item = array('other_product_id'=>$oModelProduct->getData('id'),
                        'other_title_of_method'=>$_REQUEST["other_title_".$i],
                        'other_link_to_price_list'=>$_REQUEST["other_link_to_price_list_".$i],
                        'other_uniform_price'=>$_REQUEST["other_uniform_price_".$i]
                    );
                    array_push($aAllDataOther,$item);
                }
            }
            $resultUpdateOMoT	= $oModelProduct->updateOMoT($oModelProduct->getData('id'),$aAllDataOther);
            //print_r($aAllDataOther); ; die();
            if(!$result_edit) {
                redir('?sMod=product_index&sSatus=updateError');
                $sErrorMsg = $oModelProduct->aLanguage['TEXT']['cannot_update'] . $oModelProduct->
                    aLanguage['TEXT']['alert_unique'];
                $oModelProduct->setErrorMsg($sErrorMsg);
            }
            else {
            }
            redir("?sMod=product_index&pUser=".$_POST['pUser']);
            break;
        }
    case 'do_edit_defaul': {
            //echo $_POST['product_payment_method_new']; die();
            foreach($_POST['product_bank']  as $bank_item){
                    if($bank_item!=""){
                            $arr_bank[]=$bank_item;
                    }
            }
            $bank_method=implode(">*",$arr_bank);
            foreach($_POST['product_other_payment_method']  as $payment_method){
                    if($payment_method!=""){
                            $arr_payment_method[]=$payment_method;
                    }
            }
            $other_method=implode(">*",$arr_payment_method);
            $ProductDefaul = array($_REQUEST['product_key_select'],
                $_REQUEST['product_key1'],
                $_REQUEST['product_key2'],
                $_REQUEST['product_key3'],
                $_REQUEST['product_key4'],
                $_REQUEST['product_key5'],
                $_REQUEST['product_store'],
                $_REQUEST['product_price'],
                $_REQUEST['product_set_limit_on_prices'],
                $_REQUEST['product_qty'],
                $_REQUEST['product_send_cash'],
                $_REQUEST['product_POD'],
                $_REQUEST['product_credit_card'],
                $_REQUEST['product_payment_method'],
                $bank_method,
                $other_method,
                $_REQUEST['product_product_status'],
                $_REQUEST['product_product_status_comment'],
                $_REQUEST['product_who_bear_the_CsOfTr'],
                $_REQUEST['product_payment_of_goods_boa'],
                $_REQUEST['product_ability_to_return_product'],
                $_REQUEST['product_ability_to_return_product_comment'],
                $_REQUEST['product_province_id'],
                $_REQUEST['product_shipping_area'],
                $_REQUEST['product_time_auction'],
                $_REQUEST['product_time_auction_end'],
                $_REQUEST["product_limited_assesment_of_the_bidder"],
                $_REQUEST["product_auto_extend"],
                $_REQUEST["product_end_soon"],
                $_REQUEST["product_price_fastener"],
                $_REQUEST["product_have_to_negotiate_discount"],
                $_REQUEST["product_auto_open_aution"],
                $_REQUEST["product_price_wins_minimum"],
                $_REQUEST["product_auction_notable"],
                $_REQUEST["product_title_bold_line"],
                $_REQUEST["product_bakground_color"],
                $_REQUEST["product_store_hot_auction"],
                $_REQUEST["product_icon_highlight"],
                $_REQUEST["product_icon_gift"],
                $_REQUEST["product_yahoo_point"],
                $_REQUEST["product_yahoo_point_fees"],
                $_REQUEST["product_affiliate"],
                $_REQUEST["product_remuneration_to_partner"],
                $_REQUEST["product_size_after_packet"],
                $_REQUEST["product_weight_after_packet"],
                $_REQUEST["product_use_yahoo"],
                $_REQUEST["product_set_link_to_price_list_page"],
                $_REQUEST["product_transport_goods_abroad"]);
            $ProductDefaul_name=array("product_key_select",
                "product_key1",
                "product_key2",
                "product_key3",
                "product_key4",
                "product_key5",
                "product_store",
                "product_price",
                "product_set_limit_on_prices",
                "product_qty",
                "product_send_cash",
                "product_POD",
                "product_credit_card",
                "product_payment_method",
                "product_bank",
                "product_other_payment_method",
                "product_product_status",
                "product_product_status_comment",
                "product_who_bear_the_CsOfTr",
                "product_payment_of_goods_boa",
                "product_ability_to_return_product",
                "product_ability_to_return_product_comment",
            	"product_province_id",
            	"product_shipping_area",
                "product_time_auction",
                "product_time_auction_end",
                "product_limited_assesment_of_the_bidder",
                "product_auto_extend",
                "product_end_soon",
                "product_price_fastener",
                "product_have_to_negotiate_discount",
                "product_auto_open_aution",
                "product_price_wins_minimum",
                "product_auction_notable",
                "product_title_bold_line",
                "product_bakground_color",
                "product_store_hot_auction",
                "product_icon_highlight",
                "product_icon_gift",
                "product_yahoo_point",
                "product_yahoo_point_fees",
                "product_affiliate",
                "product_remuneration_to_partner",
                "product_size_after_packet",
                "product_weight_after_packet",
                "product_use_yahoo",
                "product_set_link_to_price_list_page",
                "product_transport_goods_abroad");
            $owner_id = 0;
            $result_defaul	= $oModelProduct->updateProductDefaul($ProductDefaul,$ProductDefaul_name,$owner_id);
            //$count = count($ProductDefaul);
        	/******************
			$count = count($array);
			for ($i = 0; $i < $count; $i++) {
			}
			*******************/
            // do update other method transport
            $aAllDataOther = array();
            for ($i=1; $i<11;$i++) {
                if($_REQUEST["other_title_".$i]!='') {
                    $item = array('other_product_id'=>$owner_id,
                        'other_title_of_method'=>$_REQUEST["other_title_".$i],
                        'other_link_to_price_list'=>$_REQUEST["other_link_to_price_list_".$i],
                        'other_uniform_price'=>$_REQUEST["other_uniform_price_".$i]
                    );
                    array_push($aAllDataOther,$item);
                }
            }
            $resultUpdateOMoT	= $oModelProduct->updateOMoT_defaul($owner_id,$aAllDataOther);
            //print_r($aAllDataOther); ; die();
            if(!$result_defaul) {
                redir('?sMod=product_index&sAction=defaul&sSatus=updateError');
                $sErrorMsg = $oModelProduct->aLanguage['TEXT']['cannot_update'] . $oModelProduct->aLanguage['TEXT']['alert_unique'];
                $oModelProduct->setErrorMsg($sErrorMsg);
            } else {
                redir("?sMod=product_index&sAction=defaul&sSatus=ok");
                break;

            }

        }
    case 'find_product_form': {
            $oModelProduct->setData("do_edit_or_add_new","do_edit");
            $oViewProduct->displayFindProductIndex($oModelProduct);
            $oViewProduct->viewListProvince($oModelProduct);
            $oViewProduct->showAttributeAddNew($oModelProduct);
            $oViewProduct->displayRank($oModelProduct,'',"");
            $oViewProduct->displayBlockProductBankInputDefault($oModelProduct);
            break;
        }

    case "AJAX_GET_INFOR": {
            $oViewProduct->displayAddNewForm($oModelProduct);
            $oViewProduct->resultXML_AJAX_GET_INFOR($oModelProduct,$_REQUEST['product_id']);
            die();
            break;
        }

    case 'choose_template': {
            $oViewProduct->displayBlankProductIndex($oModelProduct);
            $template_path='/template/temp'.$_REQUEST['template_path']."/";
            $oViewProduct->ajax_display_template($oModelProduct,$template_path);
            die();
            break;
        }

    case 'choose_size': {
            $template_path = '/template/temp'.$_REQUEST['template_path']."/";
            $size_id = $_REQUEST['size_id'];
            $oViewProduct->ajax_change_size($oModelProduct,$template_path,$size_id);
            die();
            break;
        }
    default:
            unset($_SESSION['fromDate']);
            unset($_SESSION['toDate']);

            $oViewProduct->displayManagerIndex($oModelProduct);
            $oViewProduct->displayListOwner($oModelProduct);
            $oViewProduct->displayListProduct($oModelProduct);

}

$oViewProduct->displayPage($oModelProduct);
